package demo

import (
	"encoding/json"
	"fmt"

	"gorm.io/gorm"
)

func Scope() {
	Init()
	var Advanceds []*Advanced
	DB.Debug().Where("name = ?", "李元芳5").Scopes(Age23).Find(&Advanceds)

	json, _ := json.Marshal(Advanceds)
	fmt.Println(string(json))
}

func Age23(db *gorm.DB) *gorm.DB {
	return db.Where("age > ?", 23)
}
